﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

namespace Microsoft.Expression.Prototyping.Mockups
{
	using System;
	using System.Windows;
	using System.Windows.Controls;

	public enum TaskbarLocation
	{
		Bottom,
		Left,
		Top,
		Right
	}

	[TemplateVisualStateAttribute(GroupName = "TaskbarLocation", Name = "Bottom")]
	[TemplateVisualStateAttribute(GroupName = "TaskbarLocation", Name = "Left")]
	[TemplateVisualStateAttribute(GroupName = "TaskbarLocation", Name = "Top")]
	[TemplateVisualStateAttribute(GroupName = "TaskbarLocation", Name = "Right")]

	public class DesktopMockup : Control
	{
		public static readonly DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(Object), typeof(DesktopMockup), null);

		public Object Content
		{
			get { return (Object)GetValue(ContentProperty); }
			set { SetValue(ContentProperty, value); }
		}

		// --------- TaskbarLocation
		public static readonly DependencyProperty TaskbarLocationProperty = DependencyProperty.Register("TaskbarLocation", typeof(TaskbarLocation), typeof(DesktopMockup), new PropertyMetadata(TaskbarLocation.Bottom, new PropertyChangedCallback(TaskbarLocationChanged)));

		public TaskbarLocation TaskbarLocation
		{
			get { return (TaskbarLocation)this.GetValue(TaskbarLocationProperty); }
			set { this.SetValue(TaskbarLocationProperty, value); }
		}

		private static void TaskbarLocationChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
		{
			((DesktopMockup)sender).OnTaskbarLocationChanged(e);
		}

		protected virtual void OnTaskbarLocationChanged(DependencyPropertyChangedEventArgs e)
		{
			VisualStateManager.GoToState(this, this.TaskbarLocation.ToString(), true);
		}

		public Object TaskbarButtonsContent
		{
			get { return (Object)GetValue(TaskbarButtonsContentProperty); }
			set { SetValue(TaskbarButtonsContentProperty, value); }
		}

		public static readonly DependencyProperty TaskbarButtonsContentProperty = DependencyProperty.Register("TaskbarButtonsContent", typeof(Object), typeof(DesktopMockup), null);

		public Object StartMenuButtonsContent
		{
			get { return (Object)GetValue(StartMenuButtonsContentProperty); }
			set { SetValue(StartMenuButtonsContentProperty, value); }
		}

		public static readonly DependencyProperty StartMenuButtonsContentProperty = DependencyProperty.Register("StartMenuButtonsContent", typeof(Object), typeof(DesktopMockup), null);

		public bool StartMenuIsOpen
		{
			get { return (bool)GetValue(StartMenuIsOpenProperty); }
			set { SetValue(StartMenuIsOpenProperty, value); }
		}

		public static readonly DependencyProperty StartMenuIsOpenProperty = DependencyProperty.Register("StartMenuIsOpen", typeof(bool), typeof(DesktopMockup), new PropertyMetadata(false, null));

		public DesktopMockup()
		{
			base.DefaultStyleKey = typeof(DesktopMockup);
		}

		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			VisualStateManager.GoToState(this, Enum.GetName(typeof(TaskbarLocation), this.TaskbarLocation), false);
		}
	}
}